/******************************************************************************
 *
 * MotionViewer
 * Copyright (C) 2007 Sangyoon Lee, Electronic Visualization Laboratory, 
 * University of Illinois at Chicago
 *
 * This software is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either Version 2.1 of the License, or 
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
 * License for more details.
 * 
 * You should have received a copy of the GNU Lesser Public License along
 * with this software; if not, write to the Free Software Foundation, Inc., 
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * Questions or comments about MotionViewer should be directed to 
 * cavern@evl.uic.edu
 *
 *****************************************************************************/

#ifndef __VICONSUBJECT_H__
#define __VICONSUBJECT_H__

#include <string>
#include <vector>
#include <fstream>
#include <iostream>


#include "LLXMLParser.h"

#include <ogre.h>
using namespace Ogre;

// subject only has skeletal information
// interface to retrieve its structure
struct VBone
{
	std::string Name;
	double		Offset[3];
	double		Rotation[3];
	Matrix3		ParentMatrix;
	Matrix3		ParentInvMatrix;
	Matrix3		InitialMatrix;

	int         iParent;
};

class ViconSubject
{
public:
	ViconSubject(const char* name);
	~ViconSubject();
	
	void loadSubjectFile(const char* filename);
	bool writeBVHHierachy(std::ifstream &v);

	void computeQuaternion(int id, float* qt);
	void computeRotation(int id, float* rot);
	void computeMatrix(int id, Matrix3 &mat);

	int  getParentBoneID(int childId);

	std::string getName() { return m_sName;}
	std::string getFileName() { return m_sFileName; }
	std::string getFullPathName() { return m_sFullPathName;}

protected:

	void addBone(LLXMLParser *parser, DOMElement* element, Matrix3& parentMat, int parent = -1);

	std::string m_sName;
	std::string m_sFileName;
	std::string m_sFullPathName;
	std::vector<VBone> m_vBones;


};

#endif